Skip to content

Comments

SSR#2

Open
Anna-er wants to merge 2 commits intomainfrom
ssr
Open

SSR#2
Anna-er wants to merge 2 commits intomainfrom
ssr

Conversation

@Anna-er
Copy link
Owner

@Anna-er Anna-er commented Oct 17, 2023

Add SSR to project

Copy link
Collaborator

@kirill-stupakov kirill-stupakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Надо бы на Next JS переделать



const TODO_LIST_ENDPOINT = 'http://localhost:8000/todos/'
const TODO_LIST_ENDPOINT = 'http://localhost:3000/todos/'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут надо бы использовать переменные окружения

const TODO_LIST_ENDPOINT = 'http://localhost:3000/todos/'


interface item {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Типы и интерфейсы принято называть с большой буквы

completed: boolean;
}

export const getServerSideProps: GetServerSideProps<{ todolist: item[] }> = async (context) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут можно использовать TodoProps

const handleToggle = (id: number) => {
setTodos(
todos.map((todo) => {
todos?.map((todo) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А todos разве могут быть undefined?

response => response.json()
).then(
data => setTodos(todos.concat(data))
data => setTodos(todos?.concat(data))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И тут

}).then(r => {
if (r.ok) {
const newTodos = todos.filter(todo => todo.id !== id);
const newTodos = todos?.filter(todo => todo.id !== id);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И тут

<h1>Todo List</h1>
<div className="list">
{todos.map((todo) => (
{todos?.map((todo) => (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

И тут

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants